<?php
namespace Home\Controller;
use Think\Controller;
use Think\Exception;

class MessageController extends CommonController {
    public function index(){
		
		$username = I('post.username');
		$email = I('post.email');
		$tel = I('post.tel');
		$content = I('post.content');
		
		
        	if ($username == '姓名' ) {
              echo "<script type='text/javascript'> alert('请填写姓名！');window.history.go(-1);</script>" ;
				exit;
            }
            if ($email == '电子邮箱') {
				echo "<script type='text/javascript'> alert('请填写电子邮箱！');window.history.go(-1);</script>" ;
                exit;
            }
            if ($tel== '电话') {
				echo "<script type='text/javascript'> alert('请填写联系电话！');window.history.go(-1);</script>" ;
               exit;
            }
            if ($content== '详细需求') {
				
				echo "<script type='text/javascript'> alert('请填写需求！');window.history.go(-1);</script>" ;
               exit;
            }
			
			$data = array();
			$data['username'] = $username;
			$data['email'] = $email;
			$data['tel'] = $tel;
			$data['content'] = $content;
			$data['creatdate'] = date('Y-m-d H:i:s');
		

            $cid = M("Message")->add($data);
		
            if ($cid) {
                echo "<script type='text/javascript'> alert('恭喜您！提交需求成功，稍后我们工作人员与您联系！');window.history.go(-1);</script>" ;
				exit;
            }
           
    }
	
		


}